Docker : Add Images
2014/06/16 |
Add Images for container.
|
|
[1] | For exmaple, update official Ubuntu image with installing sshd and add it as a new image for container. The container is generated every time for executing docker run command, so add the latest executed container like follows. |
# show images root@dlp:~# docker images REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE ubuntu 12.10 e314931015bd 12 days ago 172.2 MB ubuntu quantal e314931015bd 12 days ago 172.2 MB ubuntu 13.10 145762641db9 12 days ago 180.2 MB ubuntu saucy 145762641db9 12 days ago 180.2 MB ubuntu 14.04 ad892dd21d60 12 days ago 275.5 MB ubuntu latest ad892dd21d60 12 days ago 275.5 MB ubuntu trusty ad892dd21d60 12 days ago 275.5 MB ubuntu raring 6b0a59aa7c48 12 days ago 169.4 MB ubuntu 13.04 6b0a59aa7c48 12 days ago 169.4 MB ubuntu 12.04 ae8682f4ff20 12 days ago 210.1 MB ubuntu precise ae8682f4ff20 12 days ago 210.1 MB ubuntu 10.04 3db9c44f4520 8 weeks ago 183 MB ubuntu lucid 3db9c44f4520 8 weeks ago 183 MB # start a Container and install openssh-server root@dlp:~# docker run ad892dd21d60 /bin/bash -c "apt-get update; apt-get -y install openssh-server" docker ps -a | head -2 CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES d19ae4713117 ubuntu:14.04 /bin/bash -c apt-get 2 minutes ago Exit 0 berserk_einstein # add the Image root@dlp:~# docker commit d19ae4713117 my_image/ubuntu_sshd b585ff101b08bedb73799f162f7c44c24491e4645f17ed89e4ed57ccb31be98d docker images # make sure root@dlp:~# docker images REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE my_image/ubuntu_sshd latest b585ff101b08 40 seconds ago 320.1 MB ubuntu 12.10 e314931015bd 12 days ago 172.2 MB ubuntu quantal e314931015bd 12 days ago 172.2 MB ubuntu 13.10 145762641db9 12 days ago 180.2 MB ubuntu saucy 145762641db9 12 days ago 180.2 MB ubuntu 14.04 ad892dd21d60 12 days ago 275.5 MB ubuntu latest ad892dd21d60 12 days ago 275.5 MB # Generate a Container from the new image and execute which command to make sure sshd exists root@dlp:~# docker run my_image/ubuntu_sshd /usr/bin/which sshd /usr/sbin/sshd |